package cn.com.connext.scrm.repository.master;


import cn.com.connext.scrm.domain.master.IndexModule;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface IndexModuleRepository extends JpaRepository<IndexModule, Long>, JpaSpecificationExecutor {
    List<IndexModule> findBySecondActivityId(@Param("secondActivityId") String secondActivityId);
    @Modifying
    @Query(value = "delete from Index_module where  id  not in :list and second_activity_id = :secondActivityId ", nativeQuery = true)
    void deleteByCondition(@Param("list") List<Long> list, @Param("secondActivityId") String secondActivityId);
    @Modifying
    @Query(value = "delete from index_module where  second_activity_id = :secondActivityId ", nativeQuery = true)
    void deleteBySecondActivityId(@Param("secondActivityId") String secondActivityId);
}
